<?php

class Authorization
{
	public function check($params)
	{

		require_once('acl.php');
		$baseURL = $GLOBALS['CFG']->config['base_url'];
		$routing =& load_class('Router');
		$class = $routing->fetch_class();
		$method = $routing->fetch_method();
		
		//Session variables extracted from cookies
		if(isset($_COOKIE) && isset($_COOKIE['ci_session'])){
			$ci_session = unserialize ($_COOKIE['ci_session']);
			if(!empty($ci_session['logged_in'])){
				$session = $ci_session['logged_in'];
			}
		}
		
		//the page is available to all
		if(!empty($allowAll[$class][$method])){
			return TRUE;
		}
		
		//The session is not initiated and the group is not set
		if(!isset($session) || !isset($session['group'])){
			
			header("location: {$baseURL}index.php/session/login");
			exit;
		}
		//the session is initiated, but the user has no access
		if(empty($allowOnly[$session['group']][$class][$method]) ||
		$allowOnly[$session['group']][$class][$method] != True){
			header("location: {$baseURL}index.php/session/login");
			exit;
		}
		
		//If we get here, authorization is succeed!
	//	return True;
	}
}
?>